<!--
 * @Author: your name
 * @Date: 2021-08-03 13:36:05
 * @LastEditTime: 2021-08-12 13:26:42
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \getHome (2)\src\components\discounts\amend.vue
-->
<!--活动管理-->
<template>
  <div>
    <div class="herdertop">
      <img src="../../assets/top.png" alt="" class="topImg" />
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>活动管理</el-breadcrumb-item>
        <el-breadcrumb-item>活动列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="center" style="padding-top: 0;">
      <div class="hander">活动列表</div>
      <div class="entirety">
        <div class="search">
          <!-- 活动名称搜索信息 -->

          <div class="demo-input-suffix">
            活动名称
            <el-input
              v-model="activityName"
              placeholder="活动名称查询"
              style="width:150px;"
            ></el-input>
          </div>
          <div class="demo-input-suffix">
            活动状态

            <el-select v-model="activityStatus" placeholder="请选择">
              <el-option
                v-for="item in business"
                :key="item.activityStatus"
                :label="item.activityName"
                :value="item.activityStatus"
              >
              </el-option>
            </el-select>
          </div>
          <!--  账号状态搜索信息 -->
          <div class="demo-input-suffix" style="margin-right:35px">
            <el-button
              style="background-color:#fd804c;color: #fff;"
              @click.native.prevent="isSelect"
              >查询</el-button
            >
            <el-button type="warning" @click.native.prevent="isEmpty"
              >清空</el-button
            >
          </div>
          <div class="news">
            <el-button
              @click.native.prevent="isAdd"
              style="position: absolute;right: 70px;"
              >新建活动
            </el-button>
            <!-- <el-button size="medium" :disabled="Num == 0 ? true : false">
              导出
            </el-button> -->
          </div>
        </div>
      </div>
      <!--  员工列表栏位-->

      <div class="entirety">
        <el-table
          ref="multipleTable"
          :data="tableData"
          tooltip-effect="dark"
          style="width: 100%"
        >
          <!-- <el-table-column type="selection" width="55"> </el-table-column> -->

          <el-table-column prop="bgImage" label="活动图片">
            <template slot-scope="scope">
              <el-image
                style="width: 70px; height: 30px"
                :src="scope.row.bgImage"
                :preview-src-list="[scope.row.bgImage]"
                :fit="'contain'"
              ></el-image>
            </template>
          </el-table-column>
          <el-table-column prop="activityName" label="活动名称">
            <template slot-scope="scope">
              <div>
                {{ scope.row.activityName }}
              </div>
            </template>
          </el-table-column>
          <el-table-column label="活动时间">
            <template slot-scope="scope">
              <div>{{ scope.row.startTime }}- {{ scope.row.endTime }}</div>
            </template>
          </el-table-column>
          <el-table-column prop="activityStatus" label="活动状态">
            <template slot-scope="scope">
              <div>
                {{
                  scope.row.activityStatus == 1
                    ? "未开始"
                    : scope.row.activityStatus == 2
                    ? "活动中"
                    : "已过期"
                }}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="updateTime" label="最近一次修改时间">
            <template slot-scope="scope">
              <div>
                {{ scope.row.updateTime }}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="updater" label="操作人">
            <template slot-scope="scope">
              <div>
                {{ scope.row.updater }}
              </div>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" width="170">
            <template slot-scope="scope">
              <el-button
                @click.native.prevent="isInfo(scope.row.activityNo)"
                style="color: #fc9e76;"
                type="text"
                size="small"
              >
                查看详情
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="block">
          <div class="left"></div>
          <div class="right">
            <el-pagination
              layout="total, sizes, prev, pager, next, jumper"
              class="page"
              @size-change="sizeChangeHandle"
              @current-change="currentChangeHandle"
              :current-page="pageIndex"
              :page-size="pageSize"
              :total="total"
            >
            </el-pagination>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      pageIndex: 1,
      pageSize: 20,
      total: 0,
      tableData: [],
      activityName: "",
      activityStatus: null,

      business: [
        {
          activityStatus: 1,
          activityName: "未开始"
        },
        {
          activityStatus: 2,
          activityName: "活动中"
        },
        {
          activityStatus: 3,
          activityName: "已过期"
        }
      ]
    };
  },
  activated() {
    this.DetailByPage();
  },

  methods: {
    isSelect() {
      (this.pageIndex = 1), (this.pageSize = 20), this.DetailByPage();
    },

    isEmpty() {
      (this.activityName = ""),
        (this.activityStatus = null),
        this.DetailByPage();
    },
    isAdd() {
      this.$router.push({
        path: "/homeActivityInfo"
      });
    },
    isInfo(activityNo) {
      this.$router.push({
        path: "/homeActivityInfo",
        query: {
          activityNo
        }
      });
    },
    // // 状态搜索
    // changeState(val) {
    //   this.activityStatus = val || "";
    //   this.DetailByPage();
    // },
    // //名称搜索
    // handleChange(activityName) {
    //   console.log("activityName,,,,,,", activityName);
    //   this.pageIndex = 1;
    //   this.DetailByPage();
    // },

    //分页获取优惠券模板列表接口调用
    DetailByPage() {
      this.$http({
        url: `/activityadmin/activity/list`,
        method: "POST",
        data: {
          activityName: this.activityName,
          activityStatus: this.activityStatus,
          pageNum: this.pageIndex,
          pageSize: this.pageSize
        }
      }).then(res => {
        this.tableData = res.data.list;
        this.total = parseInt(res.data.total);
      });
    },

    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.DetailByPage();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.DetailByPage();
    }
  }
};
</script>
<style scoped lang="scss">
.block {
  width: 100%;
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  padding: 0 10px 0 10px;
}
.left {
  font-size: 15px;
}
.hander {
  width: 100%;
  height: 50px;
  line-height: 50px;
  font-size: 20px;
  font-weight: 900;
}
.herdertop {
  height: 8vh;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
}
.topImg {
  margin-right: 20px;
}
.news {
  margin-left: 16%;
}
.entirety {
  width: 95%;
  margin: 10px;
  border: 7px solid #fafafa;
  border-radius: 10px;
  .basic {
    font-size: 18px;
    font-weight: 900;
    margin-top: 2%;
    margin-bottom: 1%;

    margin-left: 1%;
  }
}

.overall {
  width: 100%;
  height: auto;
  display: flex;

  justify-content: space-between;
  margin-top: 3%;
  .left {
    width: 20%;
    height: auto;
  }
  .right {
    width: 80%;
    height: auto;
  }
}
.demo-input-suffix {
  margin-left: 2%;
}
.select {
  width: 65%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .dialog-footer,
  .choice {
    margin-left: 2%;
  }
}
.userSearch {
  display: flex;
  /deep/ .el-input__inner {
    box-sizing: border-box;
    height: 40px;
    border-radius: 0;
    width: 132px;
    border: 1px solid #dcdfe6;
  }
  /deep/ .el-icon-arrow-up:before {
    position: relative;
    top: -4px;
  }
  /deep/ .el-button {
    height: 40px;
    border-radius: 0;
    background-color: #fff;
    border: 1px solid #dcdfe6;
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    position: relative;
    .el-icon-search {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-right: none;
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
  }
}
.selects {
  width: 55%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .dialog-footer,
  .choice {
    margin-left: 2%;
  }
}

/deep/ .but {
  background: #fd7097;
  color: #fff;
  margin-bottom: 1%;
}
</style>
